package com.eastfair.matching.controller;

import com.eastfair.annotation.annotation.log.SysLog;
import com.eastfair.auth.dto.UserAccountDto;
import com.eastfair.auth.vo.UserAccountVo;
import com.eastfair.core.base.R;
import com.eastfair.core.exception.BizException;
import com.eastfair.matching.dto.BindComplementServiceProviderRoleDTO;
import com.eastfair.matching.dto.RemoveComplementServiceProviderRoleDTO;
import com.eastfair.matching.service.ComplementRegisterService;
import com.eastfair.matching.vo.ComplementRegisterDataVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * 配套服务用户祖注册
 * </p>
 *
 * @author lyw
 * @date 2022-07-20
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/complementRegister")
@Api(value = "complementRegister", tags = "配套服务项")
public class ComplementRegisterController {
    @Autowired
    private ComplementRegisterService complementRegisterService;


    /**
     * 配套服务商注册
     *
     * @param userAccountDto 用户新增实体
     * @return
     */
    @ApiOperation(value = "配套服务商注册", notes = "配套服务商注册")
    @SysLog("配套服务商注册")
    @PostMapping("/registerComplementUser")
    public R<ComplementRegisterDataVO> registerComplementUser(@RequestBody UserAccountDto userAccountDto) {

        try {
            return R.success(complementRegisterService.registerSubSystemUser(userAccountDto));
        } catch (BizException e) {
            return R.fail(e);
        }
    }

    /**
     * 配套服务商绑定角色.
     * @param bindComplementServiceProviderRoleDTO
     * @return
     */
   @PostMapping("/bind/complementRole")
    public R<Boolean> bindComplementServiceProviderRole(@RequestBody BindComplementServiceProviderRoleDTO bindComplementServiceProviderRoleDTO){

       try {
           return R.success(complementRegisterService.bindComplementServiceProviderRole(bindComplementServiceProviderRoleDTO));
       } catch (BizException e) {
           return R.fail(e);
       }

   }

    /**
     * 配套服务商移除角色
     * @param removeComplementServiceProviderRoleDTOList
     * @return
     */
    @PostMapping("/remove/complementRole")
    public R<Boolean> removeComplementServiceProviderRole(@RequestBody List<RemoveComplementServiceProviderRoleDTO> removeComplementServiceProviderRoleDTOList){

        try {
            return R.success(complementRegisterService.removeComplementServiceProviderRole(removeComplementServiceProviderRoleDTOList));
        } catch (BizException e) {
            return R.fail(e);
        }

    }







}
